package org.ix.dynamicapis.model.request;

import org.ix.dynamicapis.constant.SortConstants;
import org.ix.dynamicapis.model.QueryRequest;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Collection;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@ApiModel(description = "接口配置查询条件请求实体")
@Getter
@Setter
@ToString
public class ApiQueryRequest extends QueryRequest {

    @ApiModelProperty(value = "接口ID")
    private Integer id;

    @ApiModelProperty(value = "接口ID列表")
    private Collection<Integer> idIn;

    @ApiModelProperty(value = "最小接口ID")
    private Integer idMin;

    @ApiModelProperty(value = "最大接口ID")
    private Integer idMax;

    @ApiModelProperty(value = "所属业务系统")
    private String systemCode;

    @ApiModelProperty(value = "所属业务系统列表")
    private Collection<String> systemCodeIn;

    @ApiModelProperty(value = "所属业务系统包含")
    private String systemCodeContains;

    @ApiModelProperty(value = "数据来源")
    private String datasource;

    @ApiModelProperty(value = "数据来源列表")
    private Collection<String> datasourceIn;

    @ApiModelProperty(value = "数据来源包含")
    private String datasourceContains;

    @ApiModelProperty(value = "接口说明")
    private String name;

    @ApiModelProperty(value = "接口说明列表")
    private Collection<String> nameIn;

    @ApiModelProperty(value = "接口说明包含")
    private String nameContains;

    @ApiModelProperty(value = "版本 (格式：v主版本号-次版本号)")
    private String version;

    @ApiModelProperty(value = "版本列表")
    private Collection<String> versionIn;

    @ApiModelProperty(value = "版本包含")
    private String versionContains;

    @ApiModelProperty(value = "主题")
    private String topic;

    @ApiModelProperty(value = "主题列表")
    private Collection<String> topicIn;

    @ApiModelProperty(value = "主题包含")
    private String topicContains;

    @ApiModelProperty(value = "接口路径")
    private String apiPath;

    @ApiModelProperty(value = "接口路径列表")
    private Collection<String> apiPathIn;

    @ApiModelProperty(value = "接口路径包含")
    private String apiPathContains;

    @ApiModelProperty(value = "是否删除(0否, 1是)")
    private Integer deleted;

    public void setIdRange(Integer[] idRange)  {
        if (idRange == null || idRange.length != 2) {
            return;
        }
        this.idMin = idRange[0];
        this.idMax = idRange[1];
    }

    public void setIdSort(SortConstants sortConstants)  {
        super.orderBy("id", sortConstants);
    }

    public void getIdSort()  {
        super.getOrderBy().getOrDefault("id", null);
    }

    public void setSystemCodeSort(SortConstants sortConstants)  {
        super.orderBy("system_code", sortConstants);
    }

    public void getSystemCodeSort()  {
        super.getOrderBy().getOrDefault("system_code", null);
    }

    public void setDatasourceSort(SortConstants sortConstants)  {
        super.orderBy("datasource", sortConstants);
    }

    public void getDatasourceSort()  {
        super.getOrderBy().getOrDefault("datasource", null);
    }

    public void setNameSort(SortConstants sortConstants)  {
        super.orderBy("name", sortConstants);
    }

    public void getNameSort()  {
        super.getOrderBy().getOrDefault("name", null);
    }

    public void setVersionSort(SortConstants sortConstants)  {
        super.orderBy("version", sortConstants);
    }

    public void getVersionSort()  {
        super.getOrderBy().getOrDefault("version", null);
    }

    public void setTopicSort(SortConstants sortConstants)  {
        super.orderBy("topic", sortConstants);
    }

    public void getTopicSort()  {
        super.getOrderBy().getOrDefault("topic", null);
    }

    public void setApiPathSort(SortConstants sortConstants)  {
        super.orderBy("api_path", sortConstants);
    }

    public void getApiPathSort()  {
        super.getOrderBy().getOrDefault("api_path", null);
    }
}
